package com.raven.craft.code.generator.common.file.metadata;

import com.raven.craft.code.generator.common.constant.FileSuffix;
import com.raven.craft.code.generator.common.util.PathUtil;

/**
 * @author raven
 * @date 2020/09/16
 **/
public class FileMetadata {

    // 文件名称
    private final String name;
    // 文件后缀
    private final FileSuffix suffix;
    // 文件路径
    private final String path;
    // 文件完整路径
    private String fullFilePath;

    public FileMetadata(String name, FileSuffix suffix, String path) {
        this.name = name;
        this.suffix = suffix;
        this.path = PathUtil.getPathWithScratch(path);
    }

    public String getFullFilePath() {
        if (fullFilePath == null) {
            fullFilePath = path + name + suffix.getCode();
        }
        return fullFilePath;
    }

    public String getName() {
        return name;
    }

    public FileSuffix getSuffix() {
        return suffix;
    }

    public String getPath() {
        return path;
    }
}
